<?php

/**
 * This Validator checks if an user with the given name is already registered in the database 
 * @author Clueth
 *
 */

class Somi_Validate_DateCheck extends Zend_Validate_Abstract {

	const NOT_MATCH = 'DateAssigned';
	 
	protected $_messageTemplates = array(
	self::NOT_MATCH => 'Das Datum müss älter sein als das andere Feld.'
	);


	public function isValid($date) {

		 
		$date = (string) $date;
		 
		$error = false;
		 
		if($this->checkUnique($user)){
			$error = true;
			$this->_error(self::NOT_MATCH);
			 
		}
		else
			return !$error;
	}

	private function dateCheck($username){

		$user = new User();
		$select = $user->select()->from('user')->where('username=?',$username);
		$result = $user->getAdapter()->fetchOne($select);

		if($result){
			return true;
		}
		return false;
	}
	 
}

?>